package study.eggs.validation.validator;

import lombok.extern.slf4j.Slf4j;
import study.eggs.exception.param.EmptyValueException;
import study.eggs.validation.constraints.Enums;

import java.lang.annotation.Annotation;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;

/**
 * 枚举验证器
 */
@Slf4j
public class DateValidator implements Validator {

    private static final List<Class> SUPPORT_LT = Arrays.asList(String.class);

    @Override
    public boolean support(Class<?> clazz) {
        boolean flag = SUPPORT_LT.stream()
                .anyMatch(e -> e == clazz);
        return flag;
    }

    @Override
    public void validate(String name, Object value, Annotation annot) {
        Enums enums = (Enums) annot;
        //非空
        if (enums.required() && Objects.isNull(value)) {
            throw new EmptyValueException(name);
        }
        //
        if (!Objects.isNull(value)) {
            String[] values = enums.values();
        }
    }
}
